package com.ecommerce.dal.entity;
// Generated May 3, 2013 3:35:49 PM by Hibernate Tools 3.6.0

import static javax.persistence.GenerationType.IDENTITY;

import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;
import javax.persistence.UniqueConstraint;

/**
 * User generated by hbm2java
 */
@Entity
@Table(name = "user", uniqueConstraints = @UniqueConstraint(columnNames = "USER_NAME"))
@Inheritance(strategy=InheritanceType.JOINED)
public class User implements java.io.Serializable {

	private String cpassword;
	
	private Long userId;
	private String userName;
	private String password;
	private String firstName;
	private String lastName;
	private boolean newsletter;
	private String gender;
	private Date birthDate;
	private Date joinDate;
	private Customer customer;
	private Client client;
	private Admin admin;
	private Set<UserCommunication> userCommunications = new HashSet<UserCommunication>(0);
	private Set<UserRole> userRole = new HashSet<UserRole>(0);
	private boolean enabled;

	public User() {
	}

	public User(String userName, String password, String firstName,
			String lastName, boolean newsletter, String gender, Date birthDate,
			Date joinDate, boolean enabled) {
		this.userName = userName;
		this.password = password;
		this.firstName = firstName;
		this.lastName = lastName;
		this.newsletter = newsletter;
		this.gender = gender;
		this.birthDate = birthDate;
		this.joinDate = joinDate;
		this.enabled = enabled;
	}

	public User(String userName, String password, String firstName,
			String lastName, boolean newsletter, String gender, Date birthDate,
			Date joinDate, Customer customer, Client client, Admin admin, boolean enabled, 
			Set<UserCommunication> userCommunications, Set<UserRole> userRole) {
		this.userName = userName;
		this.password = password;
		this.firstName = firstName;
		this.lastName = lastName;
		this.newsletter = newsletter;
		this.gender = gender;
		this.birthDate = birthDate;
		this.joinDate = joinDate;
		this.customer = customer;
		this.client = client;
		this.admin = admin;
		this.enabled = enabled;
		this.userCommunications = userCommunications;
		this.userRole = userRole;
	}

	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "USER_ID", unique = true, nullable = false)
	public Long getUserId() {
		return this.userId;
	}

	public void setUserId(Long userId) {
		this.userId = userId;
	}

	@Column(name = "USER_NAME", unique = true, nullable = false, length = 45)
	public String getUserName() {
		return this.userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	@Column(name = "PASSWORD", nullable = false, length = 45)
	public String getPassword() {
		return this.password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	@Column(name = "FIRST_NAME", nullable = false, length = 45)
	public String getFirstName() {
		return this.firstName;
	}

	public void setFirstName(String firstName) {
		this.firstName = firstName;
	}

	@Column(name = "LAST_NAME", nullable = false, length = 45)
	public String getLastName() {
		return this.lastName;
	}

	public void setLastName(String lastName) {
		this.lastName = lastName;
	}

	@Column(name = "NEWSLETTER", nullable = false)
	public boolean isNewsletter() {
		return this.newsletter;
	}

	public void setNewsletter(boolean newsletter) {
		this.newsletter = newsletter;
	}

	@Column(name = "GENDER", nullable = false, length = 6)
	public String getGender() {
		return this.gender;
	}

	public void setGender(String gender) {
		this.gender = gender;
	}

	@Temporal(TemporalType.DATE)
	@Column(name = "BIRTH_DATE", nullable = false, length = 10)
	public Date getBirthDate() {
		return this.birthDate;
	}

	public void setBirthDate(Date birthDate) {
		this.birthDate = birthDate;
	}

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "JOIN_DATE", nullable = false, length = 19)
	public Date getJoinDate() {
		return this.joinDate;
	}

	public void setJoinDate(Date joinDate) {
		this.joinDate = joinDate;
	}

	@OneToOne(fetch = FetchType.LAZY, mappedBy = "user")
	public Customer getCustomer() {
		return this.customer;
	}

	public void setCustomer(Customer customer) {
		this.customer = customer;
	}

	@OneToOne(fetch = FetchType.LAZY, mappedBy = "user")
	public Client getClient() {
		return this.client;
	}

	public void setClient(Client client) {
		this.client = client;
	}

	@OneToOne(fetch = FetchType.LAZY, mappedBy = "user")
	public Admin getAdmin() {
		return this.admin;
	}

	public void setAdmin(Admin admin) {
		this.admin = admin;
	}

	@OneToMany(fetch = FetchType.LAZY, mappedBy = "user")
	public Set<UserCommunication> getUserCommunications() {
		return this.userCommunications;
	}

	public void setUserCommunications(Set<UserCommunication> userCommunications) {
		this.userCommunications = userCommunications;
	}
	
	@OneToMany(fetch = FetchType.LAZY, mappedBy = "user")
	public Set<UserRole> getUserRole() {
		return this.userRole;
	}

	public void setUserRole(Set<UserRole> userRole) {
		this.userRole = userRole;
	}
	
	@Column(name = "ENABLED", nullable = false)
	public boolean isEnabled() {
		return this.enabled;
	}

	public void setEnabled(boolean enabled) {
		this.enabled = enabled;
	}
	
	public void setCpassword(String cpassword) {
		this.cpassword = cpassword;
	}
	
	@Transient
	public String getCpassword() {
		return cpassword;
	}
}
